package com.eminem.utils;

import com.eminem.common.StrMath;

public class PageUtil {


    public static long PageTotal(long num){
        return num % StrMath.PAGE_SIZE == 0 ? num / StrMath.PAGE_SIZE : num / StrMath.PAGE_SIZE + 1;
    }


    public static long getStartPage(long currentPage ){
        return currentPage % StrMath.PAGE_COUNT == 0 ? currentPage - StrMath.PAGE_COUNT + 1 : (currentPage - currentPage % StrMath.PAGE_COUNT) + 1;
    }


    public static long getEndPage(long currentPage,long totalCount){
        long startPage = getStartPage(currentPage);
        long pageTotal = PageTotal(totalCount);
        long endPage = startPage + StrMath.PAGE_COUNT - 1;
        return endPage >  pageTotal ? pageTotal : endPage;
    }

}
